<template>
  <view class="listitem">
    <view class="image">
      <image :src="image"></image>
    </view>
    <text class="title">{{ title }}</text>
    <text class="remark">{{ remark }}</text>
    <text class="hours">执行 {{ times }} 次,共 {{ hours }} 小时</text>
    <text class="time">该计划于 {{ createtime }} 创建</text>

    <view class="btn-do" @tap="bindDoPlan(id, title)">
      <text v-if="times <= 0">开始执行</text>
      <text v-else>继续执行</text>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    id: {
      type: Number,
      default: 0
    },
    image: {
      type: String,
      default: ''
    },
    title: {
      type: String,
      default: ''
    },
    remark: {
      type: String,
      default: ''
    },
    createtime: {
      type: String,
      default: ''
    },
    times: {
      type: Number,
      default: 0
    },
    hours: {
      type: Number,
      default: 0
    }
  },

  methods: {
    bindDoPlan (id, title) {
      if (!id || !title) return

      // 跳转至计时器界面
      this.$parent.$navigate('./plan/clock', { planId: id, planTitle: title })
    }
  }
}
</script>

<style lang="less">
  .listitem {
    position: relative;
    display: flex;
    align-items: center;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background-color: #fff;
    box-sizing: border-box;
    border-radius: 5px;
    box-shadow: 0 0 12px 2px rgba(0,0,0,.08);
    .image{
      margin-top: 60rpx;
      display: block;
      width: 200rpx;
      height: 200rpx;
      image {
        display: block;
        width: 200rpx;
        height: 200rpx;
      }
    }
    .title{
      font-weight: bold;
      font-size: 36rpx;
      margin-top: 30rpx;
    }
    .remark{
      font-size: 28rpx;
      padding: 30rpx;
      text-align:justify;
    }
    .time,.hours{
      display: block;
      font-size: 26rpx;
      color: #666;
    }
    .time{
      position: absolute;
      bottom: 60rpx;
    }
    .hours{
      position: absolute;
      bottom: 100rpx;
      font-weight: bold;
    }
    .btn-do{
      position: absolute;
      bottom: 180rpx;
      width: 35%;
      height: 70rpx;
      line-height: 70rpx;
      text-align: center;
      background-color: #138cff;
      color: #fff;
      font-size: 28rpx;
      transition: background-color 0.3s;
    }
    .btn-do:active{
      background-color: #0f7ce3;
    }
  }
</style>
